package com.practice.vo.user;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.practice.entity.UserDO;
import lombok.Data;

/**
 * desc
 *
 * @author: kayn
 * 2025-04-29 11:41
 **/
@Data
public class UserBO {

    /**
     * 主键(新增时传null,编辑时传后端返回的id)
     */
    private String id;

    /**
     * 登录账户
     */
    private String loginName;

    /**
     * 登录密码
     */
    private String loginPassword;

    /**
     * 头像
     */
    private String icon;

    /**
     * 昵称
     */
    private String userName;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 用户类型
     */
    private String userType;



    public UserDO toDO() {
        UserDO userDO = new UserDO();
        userDO.setId(StrUtil.isNotBlank(id) ? id : IdUtil.getSnowflakeNextIdStr());
        userDO.setLoginName(loginName);
        userDO.setLoginPassword(loginPassword);
        userDO.setIcon(icon);
        userDO.setUserName(userName);
        userDO.setPhone(phone);
        userDO.setEmail(email);
        userDO.setUserType(userType);
        return userDO;
    }
}
